package cn.com.coding.system.service.impl;

import cn.com.coding.common.utils.PageUtil;
import cn.com.coding.common.utils.Query;
import cn.com.coding.system.dao.ProductCategoryDao;
import cn.com.coding.system.domin.ProductCategoryEntity;
import cn.com.coding.system.service.ProductCategoryService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


@Service("productCategoryService")
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryDao, ProductCategoryEntity> implements ProductCategoryService {

    @Override
    public PageUtil queryPage(Map<String, Object> params) {
        if (params.get("page") != null) {
            params.put("page", params.get("page").toString());
        }
        if (params.get("limit") != null) {
            params.put("limit", params.get("limit").toString());
        }
        QueryWrapper<ProductCategoryEntity> eq = new QueryWrapper<>();
        if (params.get("categoryStatus") != null) {
            eq.eq("category_status", params.get("categoryStatus"));
        }
        IPage<ProductCategoryEntity> page = this.page(
                new Query<ProductCategoryEntity>().getPage(params),eq
        );

        return new PageUtil(page);
    }

}